package com.hzlj.position.locate.common.dto.reportInspection;


import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fz.common.base.enums.db.ResultField;
import com.fz.common.dict.annotation.Dict;
import com.hzlj.position.config.common.dto.common.PositionHandleExtDTO;
import com.hzlj.position.locate.common.model.ReportInspection;
import com.hzlj.sqjz.jz.common.dto.common.JzCommonQueryResultDTO;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.util.Date;

import static com.fz.common.base.core.date.DateUtils.*;

/**
 * 通信联络核查-核查(ReportInspection)查询结果返回DTO
 *
 * @author lifh
 * @date 2023-03-13 19:22:32
 */
@Data
@ToString
@Accessors(chain = true)
public class ReportInspectionWithJzJbxxDTO extends JzCommonQueryResultDTO {
    /**
     * 主键
     */
    @ResultField(ReportInspection.class)
    private String id;
    /**
     * 所属天
     */
    @ResultField(ReportInspection.class)
    @JsonFormat(locale = LOCALE, timezone = TIME_ZONE, pattern = DATE_SHORT_FORMAT)
    private Date belongDay;
    /**
     * 点验方式,dict-REPORT_TYPE
     */
    @ResultField(ReportInspection.class)
    @Dict("REPORT_TYPE")
    private String reportType;
    /**
     * 点验方式,dict-REPORT_TYPE(文本)
     */
    private String reportTypeText;
    /**
     * 人工上报状态,dict-REPORT_STATUS
     */
    @ResultField(ReportInspection.class)
    @Dict(value = "REPORT_STATUS")
    private String reportStatus;
    /**
     * 人工上报状态,dict-REPORT_STATUS(文本)
     */
    private String reportStatusText;
    /**
     * 纬度
     */
    @ResultField(ReportInspection.class)
    private String latitude;
    /**
     * 经度
     */
    @ResultField(ReportInspection.class)
    private String longitude;
    /**
     * 上报时间
     */
    @ResultField(ReportInspection.class)
    private Date reportTime;
    /**
     * 上报地址
     */
    @ResultField(ReportInspection.class)
    private String reportAddress;
    /**
     * 上报的现场图片
     */
    @ResultField(ReportInspection.class)
    private String fileIds;
    /**
     * 点验通知是否发送成功
     */
    @ResultField(ReportInspection.class)
    private Boolean notice;
    /**
     * 点验通知是否发送失败原因
     */
    @ResultField(ReportInspection.class)
    private String noticeFailMsg;
    /**
     * 核查时间
     */
    @ResultField(ReportInspection.class)
    private Date spotCheckTime;
    /**
     * 最近的实际核查时间，如果为空，代表还没有发送
     */
    @ResultField(ReportInspection.class)
    private Date actualSpotCheckTime;
    /**
     * 最大的延迟上报分钟数，必须在spot_check_time+max_delay_report_minutes之前上报
     */
    @ResultField(ReportInspection.class)
    private Integer maxDelayReportMinutes;
    /**
     * 是否已经处理,dict-HANDLE_STATUS
     */
    @Dict("HANDLE_STATUS")
    @ResultField(ReportInspection.class)
    private String handleStatus;
    /**
     * 是否已经处理,dict-HANDLE_STATUS(文本)
     */
    private String handleStatusText;
    /**
     * 异常处理内容
     */
    private PositionHandleExtDTO handleExt;
    /**
     * 是否越界
     */
    @ResultField(ReportInspection.class)
    private Boolean crossBorder;
    /**
     * 额外参数,json-ReportInspectionExtDTO
     */
    @ResultField(ReportInspection.class)
    private ReportInspectionExtDTO ext;
    /**
     * 是否已读
     */
    @ResultField(ReportInspection.class)
    private Boolean read;
    /**
     * 已读时间
     */
    @ResultField(ReportInspection.class)
    private Date readTime;
    /**
     * 创建者JgCode
     */
    @ResultField(ReportInspection.class)
    private String creatorJgCode;
    /**
     * 创建者JgMc
     */
    @ResultField(ReportInspection.class)
    private String creatorJgMc;

    public String getNoticeText() {
        if (ObjectUtil.isEmpty(notice)) {
            return "/";
        }
        return Boolean.TRUE.equals(notice) ? "已下发" : "下发失败";
    }

    public String getCrossBorderText() {
        if (ObjectUtil.isEmpty(crossBorder)) {
            return "/";
        }
        return Boolean.TRUE.equals(crossBorder) ? "越界" : "正常";
    }

    public String getReadText() {
        return Boolean.TRUE.equals(read) ? "已读" : "未读";
    }

    public String getReportStatusText() {
        return reportStatusText;
    }
}

